package com.zjitc.chapter12.controller;

import com.zjitc.chapter12.domain.Order;
import com.zjitc.chapter12.domain.Product;
import com.zjitc.chapter12.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;
import java.util.Set;

@Controller
public class OrderController {
    @RequestMapping("/showOrders")
    public void showOrders(User user) {
        System.out.println("UserController.showOrders");
        System.out.println("user = " + user);
    }
    @RequestMapping("/orderInfo")
    public void getOrderInfo(Order order) {
        Integer orderId = order.getId();
        Map<String, Product> productInfo = order.getProductInfo();
        Set<String> keys = productInfo.keySet();
        for (String key : keys) {
            Product product = productInfo.get(key);
            System.out.println("orderId = " + orderId);
            System.out.println("key = " + key);
            System.out.println("product = " + product);
        }
    }
}
